<?php
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: admuserscriptcvsgen.php,v $ 
 * $Date: 2005/08/29 15:31:25 $ 
 * $Revision: 1.2 $ 
 * 
 * ********* CVS HEADER ********* 
 */
require_once ("module/TPLN/TPLN.php");
$TPLN = new TPLN;

$TPLN -> Open($op_basepath."tpl/admuserscriptcvsgen.html");
$TPLN -> IncludeFile("header", "environnement/".$session["environnement"]."/header.php");
$TPLN -> IncludeFile("footer", "environnement/".$session["environnement"]."/footer.php");
include("param/autouser.php");
/*
Delimiteur CSV: $del = ':';
Prototype d'une ligne du fichier CSV: $prototype = '[ID]:[LOGIN]::[PASSWORD]';
Script que l'on veut multiplier: $myScript = 'temp/test.php';
Fichier CSV en entree: $csv_file;
Fichier de sortie: $exit_file = 'temp/exit.php';
*/

$L_bloc="genere";
if($genere==1) {
	$prototype=str_replace("*","[NADA]",$prototype);
	$item = explode($del,$prototype);
	$csv_tab = file($csv_file,'r');
	$pExit_file = fopen($exit_file,'w');
	$script = implode("\n", file($myScript));
	$i = count($csv_tab);
	while($i>0) {
      		$val = explode($del,current($csv_tab));
      		next($csv_tab);
      		$ligne = str_replace($item,$val,$script);
      		fputs($pExit_file,$ligne);
      		$i--;
	}
	fclose($pExit_file);
	$TPLN -> Parse( $L_bloc.".exit_file", $exit_file);
	$genere=0;
} else {
	$TPLN -> EraseBloc($L_bloc);
}

$L_bloc="execute";
if($execute==1) {
	include($exit_file);
	$TPLN -> Parse( $L_bloc.".exit_file", $exit_file);
	$execute=0;
} else {
	$TPLN -> EraseBloc($L_bloc);
}

$L_bloc="supprime";
if($delete==1) {
	unlink($exit_file);
	$TPLN -> Parse( $L_bloc.".exit_file", $exit_file);
	$delete=0;
} else {
	$TPLN -> EraseBloc($L_bloc);
}

$TPLN->Write();

?>